<script>
import {
  findComponentDownward,
  findComponentUpward
} from '@admin/utils/index'
export default {
  name: 'SlotRender',
  props: {
    name: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      commonInstance: null
    }
  },
  provide() {
    return {
    }
  },
  beforeMount: function() {
    const commonInstance = findComponentUpward(this, 'CommonPage')
    if (commonInstance) {
      this.commonInstance = commonInstance
    } else {
      this.commonInstance = findComponentDownward(findComponentUpward(this, 'AppMain'), 'CommonPage')
    }
  },
  mounted: function() {
  },
  methods: {
  },
  render: function(h) {
    const slot = this.commonInstance.$slots[this.name]
    if (slot) {
      return slot()
    }
    return ''
  }
}
</script>
<style lang="scss" scoped>
</style>

